home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 2382 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.6 KB

  1. Path: newsbf02.news.aol.com!not-for-mail
  2. From: awhang8367@aol.com (AWhang8367)
  3. Newsgroups: comp.lang.c++
  4. Subject: === Repost : Interrupt driven object ===
  5. Date: 17 Jan 1996 09:11:40 -0500
  6. Organization: America Online, Inc. (1-800-827-6364)
  7. Sender: root@newsbf02.news.aol.com
  8. Message-ID: <4dj02s$60q@newsbf02.news.aol.com>
  9. Reply-To: awhang8367@aol.com (AWhang8367)
  10. NNTP-Posting-Host: newsbf02.mail.aol.com
  11.  
  12.  
  13. >In article <4d6imm$okq@newsbf02.news.aol.com>, awhang8367@aol.com says...
  14. >
  15. >  I have been struggling to create an object that handles hardware
  16. >interrupt directly.  Particularly with the setvect function as it takes
  17. in
  18. >pointers to interrupts 
  19. >and not to objects.  Two things I can do (and I have accomplished ther
  20. >former):
  21. >
  22. >   1)  Use an interrupt service routine to call the object.
  23. >   2)  directly write the address of the member function to the Interrupt
  24. >vector table
  25. >
  26. >  Both implementations seems to be very clumsy.  Does anyone know of a
  27. >good way of doing it?  Any pointer or email interrupt will be greatly
  28. >appreciated.
  29. >
  30. > =======================================================
  31.  
  32.  
  33.   This is a repost of the above question.
  34.   
  35.   Platform  : MS-DOS
  36.   Compiler :  BC++ 4.52
  37.   Objective : To create an object that intercepts interrupt
  38.   Problem   : Unable to use setvect() to point interrupt to
  39.               objects "member interrupt function".  
  40.               The following code illustrates:
  41.  
  42. class serial_device:public UART
  43. {
  44.   private :
  45.    .
  46.    .
  47.    .
  48.    .
  49.  
  50.   public :
  51.   void interrupt far isr(...);
  52.   serial_device()
  53.   {
  54.     .
  55.     .
  56.     .
  57.     setvect(0xb,isr);
  58.  
  59.     // The above line causes these error messages :
  60.     //   1) Error SOURCE\SERIAL.CPP 79: Member function 
  61.     //      must be called or its address taken in function 
  62.     //      serial_device::serial_device()
  63.     //
  64.     //   2) Error SOURCE\SERIAL.CPP 79: Type mismatch in 
  65.     //      parameter '__isr' in call to 'setvect(int,void (interrupt
  66. *)(...))' 
  67.     //      in function serial_device::serial_device()
  68.     //
  69.     //  Also tried using the following to no avail :
  70.     //
  71.     //  setvect(0xb,&serial_device::isr)
  72.     //  setvect(0xb,(interrupt*)&serial_device::isr)
  73.     //
  74.   }
  75.   
  76.   ~serial_device(){};
  77.    {
  78.     .
  79.     .
  80.     .
  81.    }
  82.  
  83. };
  84.  
  85.  
  86. // ===============================================
  87.   Referring to my original posting the first 
  88. method looks like this:
  89.  
  90. class serial_device:public UART
  91. {
  92.   private :
  93.    .
  94.    .
  95.    .
  96.    .
  97.  
  98.   public :
  99.   void isr();
  100.   serial_device()
  101.   {
  102.    .
  103.    .
  104.    .
  105.   }
  106.   
  107.   ~serial_device(){};
  108.    {
  109.     .
  110.     .
  111.     .
  112.    }
  113.  
  114. };
  115.  
  116. serial_device Scanner;
  117.  
  118. void interrupt far interrupt_isr(...)
  119. {
  120.   asm sti;
  121.   Scanner.isr();
  122.   outp(0x20,0X20) ; 
  123. }
  124.